<template>
  <div class="server">
    <div class="customerService" style="padding:200px">
      <Form ref="formInline" :model="formInline" :rules="ruleInline" :label-width="120">     
          <FormItem label="会员等级名称" prop="vip_name">
              <Input type="text"  v-model="formInline.vip_name" placeholder="会员等级名称">
                  
              </Input>
          </FormItem>
          <FormItem label="vip页面内容" prop="vip_content">
              <tinymce  ref="editor" v-model = "formInline.vip_content"></tinymce>
          </FormItem>
          <FormItem style="text-align: center;margin-top:20px">
              <Button style="width:100%" type="primary" @click="handleSubmit('formInline')">完成</Button>
          </FormItem>
      </Form>
    </div>
  </div>
</template>
<script>
import uploadImg from '@/components/uploadImg'
import tinymce from '@/components/tinymce'
export default {
   data() {
    return {
      formStyle:'width:320px;height:150px;line-height:150px',
      formInline: {
        vip_name:'',
        vip_content:'',
      },
      ruleInline: {
          vip_name: [
              { required: true, message: '请填写会员等级名称', trigger: 'blur' },
          ],
          vip_content: [
              { required: true, message: '请填写内容', trigger: 'blur' },
          ],
      }
    }
  },
  mounted() {
    this.getDatas();
  },
  methods: {
    getDatas(){
      let params = {
         opt: 1
      }
      this.$api.getseverdetail(params)
          .then(res => {
            console.log(res);
            if (res.code == 200) {
              this.formInline.vip_name = res.data.vip_name
              this.formInline.vip_content = res.data.vip_content
          }
      })
    },
    handleSubmit(value){
        let params = {
          vip_name:this.formInline.vip_name,
          vip_content:this.formInline.vip_content,
        };
        this.$api.editsever(params)
          .then(res => {
            console.log(res);
            if (res.code == 200) {
              this.$Message.success('设置成功');
              this.getDatas();
            }
        })    
    },
  },
  components: {
    tinymce,
    uploadImg
  }
}
</script>
<style lang="less" scoped>
    @import './index.less';
</style>
